package com.imu.purse.modules.app.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.imu.purse.modules.app.entity.UserCheckEntity;
import com.imu.core.base.BaseMapper;

/**
 * 
 * @author sunhongwei
 * @email sunhongwei@jshijian.com
 * @date 2018-07-19 14:30:09
 * Copyright (c) 2017 武汉极时间科技有限公司 版权所有 
 * Jshijian aloha CO.,LTD. All Rights Reserved. 
 */
public interface UserCheckMapper extends BaseMapper<UserCheckEntity>
{
	/**
     * 分页查询
     * @param pageNo 页号
     * @param pageSize 每页显示记录数
     * @return
     */
	@Select({
		"<script>",
		    "SELECT id,",
					"user_id, ",
					"imei, ",
					"check_type, ",
					"check_value, ",
					"time_create",
		    "FROM imu_user_check ",
		    "WHERE 1=1",
			"<when test = 'userId != null'>",
		    	"AND `user_id` = #{userId}",
		    "</when>",
		    "ORDER BY cs DESC",
    	"</script>"
	})
    public List<UserCheckEntity> findByPage(final UserCheckEntity entity);	
	
	/**
	 * 根据用户id真删除校验信息
	 * @param userId
	 * @return
	 */
	@Delete({
		"delete from imu_user_check where USER_ID = #{userId}"
	})
	public int deleteByUserId(@Param("userId")Long userId);
}
